package com.huabo.system.service.impl;


import com.hbfk.entity.DealUserToken;
import com.hbfk.entity.TblStaffUtil;
import com.hbfk.util.PageInfo;
import com.huabo.system.mysql.entity.TblYyUserQueryMySql;
import com.huabo.system.mysql.mapper.TblYyOrgDepositMySqlMapper;
import com.huabo.system.oracle.entity.TblYyUserQuery;
import com.huabo.system.oracle.mapper.TblYyOrgDepositMapper;
import com.huabo.system.service.TblYyOrgDepositService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class TblYyOrgDepositServiceImpl implements TblYyOrgDepositService {

    @Autowired
    private TblYyOrgDepositMapper tblYyOrgDepositMapper;

    @Autowired
    private TblYyOrgDepositMySqlMapper tblYyOrgDepositMySqlMapper;

    @Override
    public Map<String, Object> findCostPircePageInfo(Integer pageNumber, Integer pageSize, TblYyUserQuery yuq, String token, String staffId) {
        Map<String, Object> resultMap = new HashMap<String, Object>(0);
        try {
            TblStaffUtil staff = DealUserToken.parseUserToken(token);
            PageInfo<TblYyUserQuery> pageInfo = new PageInfo<TblYyUserQuery>();
            pageInfo.setCurrentPage(pageNumber);
            pageInfo.setPageSize(pageSize);
            yuq.setOrgid(staff.getCurrentOrg().getOrgid());
            //yuq.setStaffid(staff.getStaffid());
            pageInfo.setCondition(yuq);
            pageInfo.setTlist(tblYyOrgDepositMapper.selectListByPageInfo(pageInfo));
            pageInfo.setTotalRecord(tblYyOrgDepositMapper.selectCountByPageInfo(pageInfo));
            resultMap.put("code", "1");
            resultMap.put("msg", "数据访问成功");
            resultMap.put("data", pageInfo);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return resultMap;
    }

    @Override
    public Map<String, Object> findMySqlCostPircePageInfo(Integer pageNumber, Integer pageSize, TblYyUserQueryMySql yuq, String token, String staffId) {
        Map<String, Object> resultMap = new HashMap<String, Object>(0);
        try {
            TblStaffUtil staff = DealUserToken.parseUserToken(token);
            PageInfo<TblYyUserQueryMySql> pageInfo = new PageInfo<TblYyUserQueryMySql>();
            pageInfo.setCurrentPage(pageNumber);
            pageInfo.setPageSize(pageSize);
            yuq.setOrgid(staff.getCurrentOrg().getOrgid());
            //yuq.setStaffid(staff.getStaffid());
            pageInfo.setCondition(yuq);
            pageInfo.setTlist(tblYyOrgDepositMySqlMapper.selectListByPageInfo(pageInfo));
            pageInfo.setTotalRecord(tblYyOrgDepositMySqlMapper.selectCountByPageInfo(pageInfo));
            resultMap.put("code", "1");
            resultMap.put("msg", "数据访问成功");
            resultMap.put("data", pageInfo);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return resultMap;
    }


}
